package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class DVDCollection here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class DVDCollection
{
    private DVD dvd;
    private ArrayList<DVD> dvdCollection;
    
    public DVDCollection()
    {
        dvdCollection = new ArrayList<DVD>();
    }
    
    public void createDVD(int no, String title, String releaseDate)
    {
        dvd = new DVD(no, title, releaseDate);
        dvdCollection.add(dvd);
    }
    
    public void addDVD(DVD d)
    {
        dvdCollection.add(d);
    }
    
    public void removeDVD(String t)
    {
        dvdCollection.remove(findDVD(t));
    }
    
     public DVD findDVD(String t)
    {
        DVD dvd = null;
        int i = 0;
        boolean found = false;
        while(i < dvdCollection.size() && !found)
        {
            dvd = dvdCollection.get(i);
            if(dvd.getTitle().equals(t))
            {
                found = true;
            }
            else
            {
                i++;
            }
        }
        
        if (found)
        {
            return dvdCollection.get(i);
        }
        else
        {
            return null;
        }
    }
    
    public void listAllDVDs()
    {
        System.out.println('\f');
        for(DVD d : dvdCollection)
        {
            System.out.println(d.getTitle()+'\n');
        }
    }
    
    public void addCopy(String t, String serialNumber, String purchaseDate, String purchasePrice)
    {
        findDVD(t).createDvdCopy(serialNumber, purchaseDate, purchasePrice);
    }
}
